package groovy.script

import groovy.sql.*
import groovy.database.Util
import groovy.sql.Sql

println "开始初始化数据库... "

Util.execute { Sql db ->
	db.execute("""
		drop table user;
	""")	
}

Util.execute { Sql db ->
	db.execute("""
		create table user(id integer primary key auto_increment,
				gender varchar(16),
				birthday varchar(128) not null,
				job varchar(128) not null,
				interest varchar(128) not null,
				introduce varchar(1024) not null,
				account varchar(128) unique not null, 
				password varchar(128) not null) default charset=utf8;		
	""")	
}

Util.execute { Sql db ->
	String str = """
		insert into user(gender, birthday, job, interest, introduce, account, password)
			values('男','2000-05-12','无业','没兴趣','这个人很懒 ，什么都没有写...','admin','123456')
	"""

	db.executeInsert(str)
}

println "数据库初始化完毕 "